<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="js/jquery-3.4.1.min.js"></script>
<script>
   $(function(){
	   $(":input[name=telephone]").blur(function(){
		   if(this.value=="")
			   return;
		   var t=this;
		   $.post("checkTeleRepeat",{telephone:this.value},function(data){
			   $(t).next().html(data=="true"?"重复了":"可以使用");	
			   alert(typeof(data));
			   $("#BtnAdd").attr("disabled",data==true);
		   },"json");
		   /* $.ajax({
			   url:"checkTeleRepeat",
			   type:"GET",
			   data:{telephone:this.value},
			   success:function(data){//data就是servlet out.print的值
				   //alert(data);
				   
				  $("#BtnAdd").attr("disabled",data=="true");
				    
			   },
			   error:function(data){
				   alert("请求出错");
			   }
		   }); */
	   });
   });
</script>
</head>
<body>
<h2>添加新生</h2>
<form method="post" action="doAddStudent.jsp" enctype="multipart/form-data">
 <p>
  <input type="text" required="required" name="sname" placeholder="姓名"/>
 </p>
 <p>
 <input type="text" name="qq" placeholder="QQ"/>
 <input type="text" name="wechat" placeholder="微信号"/>
 <input type="text" name="telephone" pattern="\d{11,15}"  placeholder="手机号"/><span></span>
 </p>
 <p>
 年级:
 <select name="gradeid">
 	<c:forEach items="${grades}" var="g">
 	<option value="${g.id}">${g.gname}</option>
 	</c:forEach>
 	 
 </select>
 身份照照片:<input type="file" name="idcardpicture"/>
 <br/>
 <input type="submit" id="BtnAdd"/>
 </p>
</form>
</body>
</html>